Three-dimensional (3D) graphics systems are used in many applications including simulation trainers for aircraft and military vehicles, virtual reality applications, video games, and etc. Three-dimensional graphics systems are typically implemented on workstations and personal computers with 3D graphics hardware. The 3D graphics hardware often includes a graphics accelerator card which facilitates the creation and display of graphic imagery.
Three-dimensional graphic scenes are made up of a number of polygons which are delimited by a set of vertices. The scene is rendered as a collection of vertices or points. The vertices are combined to provide larger primitives such as triangles and etc. to create a surface. As each vertex is received from an application program, it has a set of attributes including: 1) material color, which describes the color of the object to which the vertex belongs; 2) a normal which describes the direction to which the surface is facing at that vertex; and 3) a position, a three-dimensional coordinate which describes where the vertex is located. In addition, the scene typically has a set of attributes including: 1) an ambient color, which essentially describes the amount of ambient light and 2) one or more individual light sources. One important task in 3D applications is to combine information for the vertices describing the surface (the material color, normal and position) with the information about the scene attributes, including the ambient color and the number and location of light sources, to produce a color for the object which accurately reflects the appearance of the object under real lighting.
Because this approach is computationally expensive, many applications limit the number of light sources used. Each light source has a number of properties associated with it including: 1) direction (a vector in the same sense as a normal vector) and 2) colors, including an ambient color, a diffuse color and a specular color. These are used to model different types of reflection from an object.
A number of computational models are known. One such model is referred to as `OpenGL`. OpenGL is a graphics library which is an industry-standard 3D API (Application Programming Interface). OpenGL models three different types of reflection: ambient, diffuse and specular. `Ambient` is the contribution of light from the scene. `Diffuse` is the contribution of light that is reflected and scattered in all directions by an object. `Specular` has to do with the color and intensity of the light used to control reflections.
When the attributes of all light sources and the attributes of the surfaces are known, one can begin to evaluate the lighting equation. Lighting is generally computed on a vertex by vertex basis for each surface. For the OpenGL lighting model, there are four components that contribute to the full lit color of a vertex. The first is `emissive`. `Emissive` is a property of the material, a property of the surface itself. It is used generally to model surfaces which give off light. For example, the surface might reflect other light while giving off light of its own, such as a light in a ceiling panel. The contribution to the intensity at a vertex is the emissive color.
Each material has an ambient color, which is an RGB (red, green, blue) color. The scene has an ambient color and the lights have an ambient color. The ambient contributions of the scene and the lights all shine on the surface and are reflected by the surface. The ambient color of the scene and each light and the intensity of the ambient material color with respect to reflectivity determine the brightness of the reflected image due to ambient lighting. Hence, for example, the red components are multiplied together, the green components are multiplied together and the blue components are multiplied together. The components computed for each light source are then summed at each vertex to determine the total amount and color of ambient light reflected.
The `diffuse` parameter refers to OpenGLs modeling of direct illumination from the light sources. As light strikes the surface it is scattered in all directions. Dull surfaces are mainly diffuse, a function of the intensity of the lights and the intensity of the surface with respect to its reflectivity. Hence, black surfaces will reflect less than a white surface. The degree of reflection is also a function of the angle of the incident light.
Evaluation of diffuse surfaces begins with a dot product between the normal at a vertex and the light direction. The dot product is a well-known mathematical (geometric) construct by which the x components are multiplied together, then the y components, then the z components. The resulting products are added together to yield a number which represents an angle. As each vector is of unit length, the dot products will range between .+-.1, where `+1` means that the light strikes the surface directly, `0` means the light is parallel to the surface, and `-1` means the light is directly behind the surface. The dot product is used to control whether or not the product of the diffuse light and the diffuse material is seen from a given point of view. For example, if the dot product is negative, then the light is behind the object and there is no possibility of the light scattering off the surface of the object into the eye as the object is blocking the light.
To finish evaluating diffuse colors, the color components are multiplied together, and each is multiplied by the dot product. The components computed for each light source are then summed.
The `specular` parameter refers to OpenGL's modeling of intense highlights that are reflected off of a surface. Again, if the dot product evaluated above is negative, there is no specular reflection as well as no diffuse reflection. If the light is in front of the object and the normal vector is halfway between the direction of the light and the direction to the eye, then the reflection is `ideal` as the angle of incidence matches the angle of reflection. Computationally, the average of the light direction vector and the eye direction vector is computed to ascertain a `half-vector`. If the half-vector is lined up perfectly with the normal, then the reflection is deemed to be ideal and the reflection of light is perfect into the eye. In other words, the reflection is perfect if the angle of reflection is equal to the angle of the eye vector. In any event, the model takes into account three directions, the light direction, the normal of the surface and the direction to the eye from the surface.
The specular contribution is evaluated first by taking the dot product and multiplying the colors again to determine the color of the reflected light. The dot product is raised to a power which may be specified by the user. If the power is very large, the exponentiation will make specular highlights small unless the dot product is close to the ideal reflection of 1. For example, if the dot product is 1/2, and it is raised to high powers, say 50 or 100, then the specular contribution will be close to zero.
Hence, there are four calculations to be made for each illumination source. For emissive, there is simply a particular value to be associated with the source. For ambient, colors are multiplied. To evaluate diffuse, a dot product is evaluated, then colors are multiplied together and then the colors are multiplied with the dot product. For specular contributions, if the object is not blocking the source, then another dot product is evaluated, an exponent is taken, and the colors are multiplied together and then, by the exponentiated dot product, the four values are then summed to produce a final color.
Although the graphics hardware uses fixed point arithmetic, all of the calculations are typically performed in floating point arithmetic. That is, after evaluating the lighting calculations, an RGBA color is determined using floating point arithmetic. This information is typically provided from a processor to a graphics accelerator card and includes the location of each of the vertices (x, y, and z (transformed)) and the RGB color information (r, g, b, and .alpha., where .alpha. is a parameter which relates to transparency). The color information is typically provided to the graphics accelerator as a packed (fixed point output) 32-bit value for each vertex.
In some applications, a number of the required processing steps is performed by a graphics accelerator card. Within the processor, vertices and attributes are provided by an application program along with lighting parameters through a standard programming interface, such as the OpenGL library. The vertices are transformed by the processor or the graphics hardware, depending on the system, and input to a lighting unit. In the lighting unit, the transformed lighting parameters are evaluated with respect to the emissive, ambient, diffuse and specular features in floating point arithmetic. Next, these values are added and converted to fixed point arithmetic. The resulting polygons are clipped and sent to the hardware. The lighting unit thereby outputs vertices with packed colors.
As a result, the conventional technique for performing lighting calculations in computer generated full color 3D applications is computationally expensive. Hence, a need exists in the art for a system and technique for reducing the computational complexity of the lighting calculations.